<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
  <title>EPICS exampleJava/arrayPerformance</title>
  <link rel="stylesheet" type="text/css"
  href="http://epics-pvdata.sourceforge.net/base.css" />
  <link rel="stylesheet" type="text/css"
  href="http://epics-pvdata.sourceforge.net/epicsv4.css" />
  <style type="text/css">
/*<![CDATA[*/
     .about { margin-left: 3em; margin-right: 3em; font-size: .83em}
     table { margin-left: auto; margin-right: auto }
     .diagram { text-align: center; margin: 2.5em 0 }
     body { margin-right: 10% }
/*]]>*/</style>

 <!-- Script that generates the Table of Contents -->
  <script type="text/javascript" src="http://epics-pvdata.sourceforge.net/script/tocgen.js"></script>

</head>

<body>

<div class="head">
<h1>EPICS exampleJava/arrayPerformance</h1>
<h2 class="nocount">2016.08.26</h2>


<h2 class="nocount">Abstract</h2>
<p>arrayPerformance provides main programs that demonstrate performance
of large arrays and can also be used to check for memory leaks.
Checking for memory leaks can be accomplished by running the programs with valgrind
or some other memory check program.
</p>
</div> <!-- head -->

<div id="toc">
  <h2 class="nocount">Table of Contents</h2>
</div>

<!-- Place what you would like in the Table of Contents, inside the contents div -->
<div id="contents" class="contents">	  
<hr />

<h2>Overview</h2>
<p>The programs are:</p>
<dl>
   <dt>arrayPerformanceMain</dt>
     <dd>This is server and also a configurable number of longArrayMonitor clients.
     The clients can use either the local or
    remote providers. The monitor code is the same code that is used by longArrayMonitorMain.
     </dd>
   <dt>longArrayMonitorMain</dt>
     <dd>Remote client that monitors the array served by arrayPerformanceMain.</dd>
   <dt>longArrayGetMain</dt>
     <dd>Remote client that uses channelGet to access the array served by arrayPerformanceMain.</dd>
   <dt>longArrayPutMain</dt>
     <dd>Remote client that uses channelPut to access the array served by arrayPerformanceMain.</dd>
</dl>
<p>Each has support for <b>-help</b>.</p>
<pre>
mrk&gt; pwd
/home/epicsv4/master/exampleJava/arrayPerformance
mrk&gt; scripts/arrayPerformance -help
recordName size delay providerName nMonitor
default
arrayPerformance 10000000 0.0001 local 1

mrk&gt; scripts/longArrayMonitor -help
channelName
default
arrayPerformance

mrk&gt; scripts/longArrayGet -help
channelName iterBetweenCreateChannel iterBetweenCreateChannelGet delayTime
default
arrayPerformance 0 0 1

mrk&gt; scripts/longArrayPut -help
channelName arraySize iterBetweenCreateChannel iterBetweenCreateChannelPut delayTime
default
arrayPerformance 10 0 0 1

mrk&gt; 
</pre>
<h2>Example output</h2>
<p><b>Note:</b> These may fail if run on a platform that does not have sufficient memory,</p>
<p>To see an example just execute the following commands in four different terminal windows:</p>
<pre>
scripts/arrayPerformance
scripts/longArrayMonitor
scripts/longArrayGet
scripts/longArrayPut
</pre>
<p>Each program generates a report every second when it has something to report.
Examples are:</p>
<pre>
scripts/arrayPerformance
arrayPerformance 10000000 0.0001 local 1 2 0
...
arrayPerformance value 34 time 1.055 Iterations/sec 10.42654028436019 megaElements/sec 104.26540284360189
 monitors/sec 11 first 35 last 35 changed {1, 2} overrun {} megaElements/sec 103.09278350515464
arrayPerformance value 44 time 1.002 Iterations/sec 9.980039920159681 megaElements/sec 99.80039920159682
 monitors/sec 11 first 46 last 46 changed {1, 2} overrun {} megaElements/sec 101.75763182238668
arrayPerformance value 56 time 1.088 Iterations/sec 11.029411764705882 megaElements/sec 110.29411764705881
 monitors/sec 12 first 58 last 58 changed {1, 2} overrun {} megaElements/sec 113.42155009451794
arrayPerformance value 67 time 1.037 Iterations/sec 10.607521697203472 megaElements/sec 106.07521697203472
 monitors/sec 11 first 69 last 69 changed {1, 2} overrun {} megaElements/sec 102.1355617455896
arrayPerformance value 79 time 1.035 Iterations/sec 11.594202898550726 megaElements/sec 115.94202898550725
 monitors/sec 13 first 82 last 82 changed {1, 2} overrun {} megaElements/sec 124.52107279693486
arrayPerformance value 93 time 1.025 Iterations/sec 13.658536585365855 megaElements/sec 136.58536585365854
 monitors/sec 14 first 96 last 96 changed {1, 2} overrun {} megaElements/sec 138.6138613861386
...
</pre>
<pre>
scripts/longArrayMonitor
longArrayMonitorMain arrayPerformance 2 0
...

 monitors/sec 3 first 176 last 176 changed {1, 2} overrun {1, 2} megaElements/sec 25.10460251046025
 monitors/sec 4 first 190 last 190 changed {1, 2} overrun {1, 2} megaElements/sec 29.940119760479043
 monitors/sec 4 first 203 last 203 changed {1, 2} overrun {1, 2} megaElements/sec 31.746031746031747
 monitors/sec 3 first 213 last 213 changed {1, 2} overrun {1, 2} megaElements/sec 22.900763358778626
 monitors/sec 3 first 224 last 224 changed {1, 2} overrun {1, 2} megaElements/sec 27.598896044158234
 monitors/sec 4 first 236 last 236 changed {1, 2} overrun {1, 2} megaElements/sec 31.08003108003108
 monitors/sec 3 first 246 last 246 changed {1, 2} overrun {1, 2} megaElements/sec 28.90173410404624
...
</pre>
<pre>
scripts/longArrayPut
longArrayPutMain arrayPerformance 10 0 0 1
...
put numChannelPut 0 Elements/sec 79.8819
put numChannelPut 1  Elements/sec 79.8598
...
</pre>
<pre>
scripts/longArrayGet
longArrayGetMain arrayPerformance 0 0 1
...
get kiloElements/sec 7384.61
get kiloElements/sec 8726.34
...
</pre>

<h2>arrayPerformance</h2>
<p>The arguments for arrayPerforamanceMain are:</p> 
<dl>
  <dt>recordName</dt>
     <dd>The name for the arrayPerform record.</dd>
  <dt>size</dt>
     <dd>The size for the long array of the value field.</dd>
  <dt>delay</dt>
      <dd>The time in seconds to sleep after each iteration.</dd>
  <dt>providerName</dt>
      <dd>The name of the channel provider for the longArrayMonitors 
      created by the main program. This must be either <b>local</b>
      or <b>pva</b>.
      </dd>
  <dt>nMonitor</dt>
     <dd>The number of longArrayMonitors to create.</dd>
</dl>
<p>
arrayPerformance creates a PVRecord that has the structure:.
</p>
<pre>
recordName
    long[] value
    timeStamp timeStamp
    alarm alarm
</pre>
Thus it holds an array of 64 bit integers.
<p>arrayPerformance creates a separate thread that runs
until stop is called.
arrayPerformance does the following:</p>
<dl>
  <dt>report</dt>
    <dd>Once a second it produces a report.
     In the above example output each line starting with
    <b>ArrayPerformance</b> is an arrayPerformance report.
    </dd>
  <dt>create array</dt>
     <dd>A new array is created and each element is set equal
      to the iteration count.</dd>
  <dt>lock</dt>
     <dd>The arrayPerformance record is locked.</dd>
  <dt>Begin group put</dt>
     <dd>beginGroupReport is called.</dd>
  <dt>pvValue.put</dt>
      <dd>The value field of the record is replaced
      with newly created data.</dd>
  <dt>process</dt>
      <dd>The record is then processed. This causes the timeStamp to
       be set to the current time.</dd>
  <dt>End group put</dt>
    <dd>endGroupPut is called.</dd>
  <dt>unlock</dt>
     <dd>The arrayPerformance record is unlocked.</dd>
  <dt>delay</dt>
      <dd>If delay is greater than zero epicsThreadSleep is called.</dd>
</dl>
<h2>longArrayMonitor</h2>
<p>This is a pvAccess client that monitors an arrayPerformance record.
It generates a report every second showing how many elements has received.
For every monitor it also checks that the number of elements is &gt;0 and the
the first element equals the last element. It reports an error if either
of these conditions is not true.</p>
<p>The arguments for longArrayMonitorMain are:</p>
<dl>
  <dt>channelName</dt>
     <dd>The name for the arrayPerform record.</dd>
</dl>
<h2>longArrayGet</h2>
<p>This is a pvAccess client that uses channelGet to access an arrayPerformance record.
Every second it produces a report.</p>

<p>The arguments for longArrayGetMain are:</p>
<dl>
  <dt>channelName</dt>
     <dd>The name for the arrayPerform record.</dd>
  <dt>iterBetweenCreateChannel</dt>
      <dd>The number of iterations between destroying and recreating the channel.
      A value of 0 means never destroy and recreate.
      </dd>
  <dt>iterBetweenCreateChannelGet</dt>
      <dd>The number of iterations between destroying and recreating the channelGet.
      A value of 0 means never destroy and recreate.
      </dd>
  <dt>delayTime</dt>
     <dd>The time to delay between gets.</dd>
</dl>
<h2>longArrayPut</h2>
<p>This is a pvAccess client that uses channelPut to access an arrayPerformance record.
Every second it produces a report.</p>

<p>The arguments for longArrayPutMain are:</p>
<dl>
  <dt>channelName</dt>
     <dd>The name for the arrayPerform record.</dd>
  <dt>arraySize</dt>
     <dd>The capacity and length of the array to put to the server.</dd>
  <dt>iterBetweenCreateChannel</dt>
      <dd>The number of iterations between destroying and recreating the channel.
      A value of 0 means never destroy and recreate.
      </dd>
  <dt>iterBetweenCreateChannelPut</dt>
      <dd>The number of iterations between destroying and recreating the channelPut.
      A value of 0 means never destroy and recreate.
      </dd>
  <dt>delayTime</dt>
     <dd>The time to delay between gets.</dd>
</dl>


</div> <!-- class="contents" -->
</body>
</html>
